<?php
// 本类由系统自动生成，仅供测试用途
class IndexAction extends Action {
    public function index(){
        $this->display();

    }
    public function check(){
        $admin=M('Admin');
        $username=$_POST['username'];
        $password=$_POST['password'];
        $fcode=strtolower($_POST['code']);
        $vcode=strtolower($_SESSION['vcode']);
        $row=$admin->where("username='{$username}' and password='{$password}'")->find();
        if($row){
            if($fcode!=$vcode){
                $this->error("验证码错误！",U('Index/index'));
            }
            $_SESSION['admin_username']=$username;
            $this->success("登陆成功",U('AfterLogin/index'));
        }
        else{
            $this->error("用户名或密码错误",U('Index/index'));
        }

    }
}